package com.example.utils;

import com.example.entity.SplitDTO;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

@Component
public class SendAsyncMessagesUtil {

    @Autowired
    private RabbitTemplate rabbitTemplate;

    //定义常量
    private static final String EXCHANGE_NAME = "amq.direct";
    private static final String ROUTING_KEY_PNG = "png";
    private static final String ROUTING_KEY_NII = "nii";

    /**
     * 发送切割处理和上传png的消息
     */
    @Async
    public void sendUploadPngAsyncMessage(SplitDTO splitDTO) {
        // 发送消息
        rabbitTemplate.convertAndSend(EXCHANGE_NAME, ROUTING_KEY_PNG, splitDTO);
    }


    @Async
    public void sendUploadNiiAsyncMessage(SplitDTO splitDTO) {
        // 消息
        String message = "hello, nii!";

        // 发送消息
        rabbitTemplate.convertAndSend(EXCHANGE_NAME, ROUTING_KEY_NII, splitDTO);
    }



}
